﻿using System;
using System.Collections.Generic;
using System.IO;

namespace EvoGame.Ceeforee.Core.Helpers
{
	public class Mod
	{

		public Dictionary<string, Dictionary<string, string>> Dir { get { return dirs; } }
		public string Name { get { return name; } }
		public bool Modular;

		private Dictionary<string, Dictionary<string, string>> dirs = new Dictionary<string, Dictionary<string, string>>();
		private CivX mode;
		private string name;

		public Mod(CivX m)
		{
			mode = m;
			SetDir("Civ4", Helper.CivDir(CivX.Vanilla));
			SetDir("CivX", Helper.CivDir(mode));
		}

		public void SetMod(string mod)
		{
			string modpath = string.Format("{0}\\{1}", dirs["CivX"]["Mods"], mod);
			SetDir("Mod", modpath);
			name = mod;
		}

		public void SetDir(string key, string root)
		{
			if (dirs.ContainsKey(key)) dirs.Remove(key);
			Dictionary<string, string> dir = new Dictionary<string, string>();
			DirectoryInfo dirKey = new DirectoryInfo(root);
			dir.Add("Root", dirKey.FullName);
			dirs.Add(key, dir);
			if (key == "CivX") dirs[key].Add("Mods", String.Format("{0}\\Mods", dirs[key]["Root"]));
			dirs[key].Add("Assets", String.Format("{0}\\Assets", dirs[key]["Root"]));
			dirs[key].Add("Art", String.Format("{0}\\Art", dirs[key]["Assets"]));
			dirs[key].Add("Python", String.Format("{0}\\Python", dirs[key]["Assets"]));
			dirs[key].Add("XML", String.Format("{0}\\XML", dirs[key]["Assets"]));

			EvoGame.Core.Components.Application.Debug.Output = String.Format("Listing Directories for {0}", key);
			foreach (KeyValuePair<string, string> kvp in dirs[key])
			{
				EvoGame.Core.Components.Application.Debug.Output = kvp.Value.ToString();
			}
		}
	}
}
